/**
 *   Copyright (C) 2012  Development Solutions (DS) Software
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   The following additional terms will apply to the software provided with
 *   this file.
 *      1. Preserve the original authors’ name.
 *      2. Documenting all contributions and specify the contributor's name,
 *         the date of the contribution and some email to future contact.
 * 
 */

package org.dss.gil.view;

import org.dss.gil.util.Globals;

/**
 *  About window
 *  @author  Fernando Gil <lobho.gil@gmail.com>
 *  @since   September 2012
 *  @version 1.0
 */
public class GlobalComments extends javax.swing.JFrame {

    private TablePanel table;
    public GlobalComments(TablePanel table) {
        initComponents();
        setIconImage(Globals.logoImg);
        setLocationRelativeTo(null);
        this.table = table;
    }

    /*********************************************************************
     ************************* M E T H O D S *****************************
     *********************************************************************/
    public void setText(String errors){
        jTextComment.setText(errors);
    }
    
    public void setLabels(String title){
        setTitle(Globals.language.getMessage("title.comment") + " - "+ title );    
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextComment = new javax.swing.JTextPane();
        jButSaveComment = new javax.swing.JButton();

        jScrollPane1.setViewportView(jTextComment);

        jButSaveComment.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/dss/gil/view/img/save_x24.png"))); // NOI18N
        jButSaveComment.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButSaveCommentActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jButSaveComment)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jButSaveComment, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButSaveCommentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButSaveCommentActionPerformed
        table.setGlobalComments(jTextComment.getText(),false);
    }//GEN-LAST:event_jButSaveCommentActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButSaveComment;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextPane jTextComment;
    // End of variables declaration//GEN-END:variables
}
